/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ControlLayer;
import ModelLayer.*;
import DBLayer.*;
import java.util.ArrayList;
/**
 *
 * @author And
 */
public class CtrCustomer {

    //Print all costumers.
    public ArrayList getAllCostumers(boolean retrieveAssociation)
    {
        IFDBCustomer dbCus = new DBCustomer();
        ArrayList allCus = new ArrayList();
        allCus = dbCus.getAllCustomers(retrieveAssociation);
        return allCus;
    }
    //find customer ved hjælp af Fname, Lname, id eller phoneNo.
    public Customer findCostumerByFname(String fname, boolean retrieveAssociation)
    {
        IFDBCustomer dbCus = new DBCustomer();
        return dbCus.findCustomerByFname(fname, retrieveAssociation);
    }
    public Customer findCostumerByLname(String lname, boolean retrieveAssociation)
    {
        IFDBCustomer dbCus = new DBCustomer();
        return dbCus.findCustomerByLname(lname, retrieveAssociation);
    }

    public Customer findCostumerById(int id, boolean retrieveAssociation)
    {
        IFDBCustomer dbCus = new DBCustomer();
        return dbCus.findCustomerById(id, retrieveAssociation);
    }
    public Customer findCostumerByPhone(String phoneNo, boolean retrieveAssociation)
    {
        IFDBCustomer dbCus = new DBCustomer();
        return dbCus.findCustomerByPhone(phoneNo, retrieveAssociation);
    }
    //Insert custumer.
    public int insertCustomer(Customer cos)
    {
        IFDBCustomer dbCus = new DBCustomer();
        return dbCus.insertCustomer(cos);
    }
    //Update Customer.
    public int updateCustomer(int id, String fname, String lname, String street, int streetNo,
    String phoneNo, String email)
    {
        IFDBCustomer dbCus = new DBCustomer();
        Customer cus = new Customer();
        cus.setId(id);
        cus.setFname(fname);
        cus.setLname(lname);
        cus.setStreet(street);
        cus.setStreetNo(streetNo);
        //Cus.setZipCode(zipCode);
        cus.setPhoneNo(phoneNo);
        cus.setEmail(email);
        return dbCus.updateCustomer(cus);
    }
    //Delete Customer.
    public int deleteCustomer(int id)
    {
        IFDBCustomer dbCus = new DBCustomer();
        return dbCus.deleteCustomer(id);
    }

}
